﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace GameObjectsAndEquipment.Weapons
{
    public abstract class Weapon : Item
    {
      //  protected int damage;
        protected String weaponType = "";
        protected float power;
        internal int clipSize = 10;
        internal int clipCount = 10;
        internal int bulletsCurrentlyInClip = 0;
        internal int startingClipCount = 10;
        protected int bullets = 0;
        protected int reloadTime;
        protected int lastShotTime = 0;
        protected float speed;
        protected Boolean isShootable = false;
        protected Texture2D bulletTexture;
        protected List<Bullet> bulletsOnStage;

        public Boolean IsShootable
        {
            get { return isShootable; }
            set { isShootable = value; }
        }

        public String WeaponType
        {
            get { return weaponType; }
        }

        public int Bullets
        {
            get { return bullets; }
            set { bullets = value; }
        }

        public List<Bullet> BulletsOnStage
        {
            get { return bulletsOnStage; }
            set { bulletsOnStage = value; }
        }

        public Weapon(Vector2 position, Texture2D texture, 
                        Texture2D bulletTexture, GameObject go,
                        List<Bullet> bulletsOnStage,
                        float power = 1.0f, int reloadTime = 1000,
                        float speed = 200.0f ,int bullets = 20, String weaponType ="") 
            :base(position, texture, go)
        {
            this.power = power;
            this.bullets = bullets;
            this.reloadTime = reloadTime;
            this.speed = speed;
            this.bulletTexture = bulletTexture;
            this.lastShotTime = 0;
            this.weaponType = weaponType;
            this.bulletsOnStage = bulletsOnStage;
        }

        public override void Update(GameTime gametime)
        {
            lastShotTime += gametime.ElapsedGameTime.Milliseconds;

            if (lastShotTime >= reloadTime && bullets > 0)
            {
                isShootable = true;
            }
            else
            {
                isShootable = false;
            }

            base.Update(gametime);

        }

        public override void Use()
        {
            base.Use();
        }

        public virtual void Shoot(Vector2 destinationPoint, bool isPlayers)
        {

        }
        
    }
}
